<?php

namespace App\Http\Controllers\Api;

use App\Model\AdminTable;
use App\Model\ClassTable;
use App\Model\StorefrontTable;
use App\Repository\BaseController\ApiController;
use App\Repository\Common\ConstTable;
use App\Repository\Sys\JsonRespose;
use App\Repository\Sys\Str;

//店面
class StorefrontController extends ApiController
{

    /**
     * @api {get} /api/storefront/fields 获取店面下所有场地类型
     * @apiGroup Wap-Store
     * @apiDescription  说明: 无
     *
     * @apiParam {Int} store_id  店铺id
     *
     * @apiSuccessExample {json} Success-Response:
     *
     * {
    "code": 1,
    "msg": "操作成功!",
    "data": [
    "1" // 表示几V几   5就是5V5
    ]
    }
     */
    public function getFields()
    {
        $store_id = \Request::get('store_id');  //店面
        $where = 'storefront_id =:storefront_id';
        $param['storefront_id'] = $store_id;
        $res = \DB::select("select * from field WHERE {$where} GROUP BY type", $param);
        $list = [];
        foreach ($res as $v) {
            $v->type_text = Str::getTypeText($v->type);
            $v->type = intval($v->type);
            $list[] = $v;
        }
        return JsonRespose::success(['list' => $list]);
    }


    /**
     * @api {get} api/storefront/list 店面列表
     * @apiGroup Wap-Store
     * @apiDescription  说明: 无
     *
     *
     * @apiSuccessExample {json} Success-Response:
     *
     * {
     * "code": 1,
     * "msg": "操作成功!",
     * "data": {
     * "count": "2",
     * "list": [
     * {
     * "id": "2",
     * "store_name": "武昌",
     * "manager_name": "陈",
     * "phone": "3424252525",
     * "field_count": ""
     * },
     * {
     * "id": "1",
     * "store_name": "汉阳",
     * "manager_name": "王",
     * "phone": "1231412414",
     * "field_count": ""
     * }
     * ],
     * "page": 1
     * }
     * }
     */
    public function getList()
    {
        return JsonRespose::done(StorefrontTable::getList(1,1000,''));
    }

}